//
//  IdentitySuccessViewController.m
//  CommunityApp
//
//  Created by 秦乾龙 on 16/12/30.
//  Copyright © 2016年 秦乾龙. All rights reserved.
//

#import "IdentitySuccessViewController.h"
#import "ZYButton.h"
#import "NavView.h"
#import "WDData.h"
#define kScreenW [UIScreen mainScreen].bounds.size.width
#define kScreenH [UIScreen mainScreen].bounds.size.height
#define kScale   ([UIScreen mainScreen].bounds.size.width)/750
@interface IdentitySuccessViewController ()<UITextFieldDelegate,UITextViewDelegate,UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,retain) UITableView *mainTableView;
@property (nonatomic,copy) UITextField *nameField;
@property (nonatomic,copy) UITextField *ideNumField;
@property (nonatomic,copy) UITextField *phoneNumField;
@property (nonatomic,copy) UITextField *codeField;
@property (nonatomic,copy) NSMutableArray *classNameArr;

@end

@implementation IdentitySuccessViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setUI];
}
- (void) setUI
{
    self.navigationItem.titleView = [ViewFactory makeNavigationTitle:@"审核结果"];
    
    UIBarButtonItem *backBtn = [ViewFactory makeNavigationBackWhite:self action:@selector(backClick)];
    self.navigationItem.leftBarButtonItem = backBtn;
    
    _mainTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,kScreenW , kScreenH-64) style:UITableViewStyleGrouped];
    _mainTableView.delegate = self;
    _mainTableView.dataSource = self;
    [self.view addSubview:_mainTableView];
    _classNameArr = [NSMutableArray arrayWithObjects:@"真实姓名：",@"身份证号码：",@"认证结果：", nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * identifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell)
    {
        cell =[[NSBundle mainBundle ]loadNibNamed:@"ZYTableViewCell" owner:nil options:nil][0];
    }
    
    //设置cell点击背景色不变
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    if (indexPath.section==0)
    {
        UIButton *boolSelectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [boolSelectBtn setImage:[UIImage imageNamed:@"提交审核成功"] forState:UIControlStateNormal];
        
        boolSelectBtn.frame = CGRectMake(300*kScale, 60*kScale, 100*kScale, 100*kScale);
        boolSelectBtn.center = CGPointMake(kScreenW/2, 110*kScale);
        
        [cell addSubview:boolSelectBtn];
        UILabel *successLable = [[UILabel alloc]init];
        successLable.text = @"认证成功";
        successLable.font = [UIFont systemFontOfSize:15];
        successLable.frame = CGRectMake(0, 29*kScale, kScreenW, 42*kScale);
        successLable.center = CGPointMake(kScreenW/2, 240*kScale);
        successLable.textAlignment = NSTextAlignmentCenter;
        [cell addSubview:successLable];
    }
    else
    {
        UILabel *classNameLable = [[UILabel alloc]init];
        classNameLable.text = [NSString stringWithFormat:@"%@",_classNameArr[indexPath.section-1]];
        classNameLable.font = [UIFont systemFontOfSize:15];
        NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],};
        //        classNameLable.textColor = [UIColor colorWithRed:158/255.0 green:158/255.0 blue:158/255.0 alpha:1.0f];
        CGSize textSize = [@"身份证号码：" boundingRectWithSize:CGSizeMake(MAXFLOAT, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;;
        classNameLable.frame = CGRectMake(30*kScale, 0, textSize.width, 100*kScale);
        classNameLable.textAlignment = NSTextAlignmentRight;
        [cell addSubview:classNameLable];
        UILabel *contentLable = [[UILabel alloc]init];
        contentLable.font = [UIFont systemFontOfSize:15];
        contentLable.frame = CGRectMake(30*kScale+textSize.width+58*kScale, 0, kScreenW-60*kScale-textSize.width-58*kScale, 100*kScale);
        contentLable.textColor = ZallColorFromRGB(0x9E9E9E);
        contentLable.textAlignment = NSTextAlignmentRight;
        if (indexPath.section==1) {
            contentLable.text = [WDData sharedWDData].reallyName;
        }
        else if (indexPath.section==2)
        {
            contentLable.text = [WDData sharedWDData].idcar;
        }
        else if (indexPath.section==3)
        {
            if ([[WDData sharedWDData].checkType isEqualToString:@"00"])
            {
                contentLable.text = @"审核通过";
            }
            else if ([[WDData sharedWDData].checkType isEqualToString:@"01"])
            {
                contentLable.text = @"未通过";
            }
            else
            {
                contentLable.text = @"待定";
            }
        }
        
        [cell addSubview:contentLable];
    }
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        return 322*kScale;
    }
    
    return  100*kScale;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return  0.01;
    }
    return 20*kScale;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
- (void)backClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)nextClick
{
    //    if (_codeField.text == _codeStr)
    //    {
    //        NextChangePhoneViewController *next = [[NextChangePhoneViewController alloc]init];
    //        [self.navigationController pushViewController:next animated:YES];
    //    }
    //    else
    //    {
    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"验证失败" message:@"请输入正确验证码" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil];
    //        [alert show];
    //    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
